package com.lancoo.znbkxx.teacher.ui.fragment

import android.annotation.SuppressLint
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.adapter.SkillDetailAdapter
import com.lancoo.znbkxx.teacher.adapter.SpacesItemDecoration
import com.lancoo.znbkxx.teacher.base.BaseFragment
import com.lancoo.znbkxx.teacher.model.data.AnswerSkillData
import com.lancoo.znbkxx.teacher.model.data.AnsweringSkill
import com.lancoo.znbkxx.teacher.utils.DensityUtils
import kotlinx.android.synthetic.main.item_header_skilldetail.view.*
import kotlinx.android.synthetic.main.view_list.*


/**
 * @author : Admin
 * @date   : 2020/10/29
 * @desc   :
 */
class SkillDetailFragment : BaseFragment() {
    private val name by lazy { arguments?.getString("name") }
    private val answerSkillList by lazy {
        arguments?.getParcelable<AnsweringSkill>("answerSkillList")
    }
    lateinit var adapter: SkillDetailAdapter
    override fun createLayout(): Int {
        return R.layout.view_list
    }

    @SuppressLint("SetTextI18n")
    override fun initView(view: View?) {
        val manager = LinearLayoutManager(requireContext())
        rv.layoutManager = manager
        adapter = SkillDetailAdapter(arrayListOf(answerSkillList!!))
        val headView = layoutInflater.inflate(R.layout.item_header_skilldetail, null)
        headView.tv_title.text = "${name}详解"
        adapter.addHeaderView(headView)
        val hashMap = hashMapOf<String, Int>()
        hashMap[SpacesItemDecoration.TOP_SPACE] = DensityUtils.dp2px(context, 5f)
        rv.addItemDecoration(SpacesItemDecoration(hashMap))
        rv.adapter = adapter
    }
}